// `process side bar
var canouri = canonial_uri();
var sr = jget('sr');
var su = jget('su');
var lock = false;
$('.auto-side').each(function(){
	data = $(this).attr('data');
	method = $(this).attr('method');
	if (typeof(data) == 'undefined' || data == null) {
		data = '';
	}
	if (data == sr && method == 'sr') {
		$(this).addClass('selected');
	}
	if (data == su && method == 'su') {
		$(this).addClass('selected');
	}
});

$('.auto-side').click(function(){
	if (lock == true) return;
	lock = true;
	data = $(this).attr('data');
	if (typeof(data) == 'undefined' || data == null) {
		data = '';
	}
	method=$(this).attr('method');
	if (typeof(method) != 'undefined' && method != null) {
		if (method == 'sr') {
			sr = data;
		} else {
			su = data;
		}
	}
	redirect = canouri;
	if (sr != '') {
		if (redirect == canouri) redirect += '?';
		else redirect += '&';
		redirect += 'sr='+sr;
	}
	if (su != '') {
		if (redirect == canouri) redirect += '?';
		else redirect += '&';
		redirect += 'su='+su;
	}
	window.location.href=redirect;
});